package com.huawei.appmarket.service.externalapi.actions;

import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.cki;
import o.Logger;
import o.due;
import o.due.d;
import o.dug;
import o.dwk;
import o.dwk.h;
import o.dyr;
import o.dys.a;
import o.ewe;

public class UpdateAppAction extends dyr {
    private static final String TAG = "UpdateAppAction";

    public UpdateAppAction(a aVar) {
        super(aVar);
    }

    public void onAction() {
        String stringExtra = new SafeIntent(this.callback.getIntent()).getStringExtra("KEY_APP_PKG");
        ApkUpgradeInfo ॱ = dug.ॱ(stringExtra);
        if (ॱ == null) {
            Logger.e(TAG, "ApkUpgradeInfo is null:" + stringExtra);
            this.callback.finish();
            return;
        }
        final dwk o_dwk = new dwk();
        o_dwk.ॱ(new cki(this) {
            final /* synthetic */ UpdateAppAction ॱ;

            {
                this.ॱ = r1;
            }

            public void ˋ() {
                this.ॱ.callback.finish();
            }
        });
        SessionDownloadTask ˏ = o_dwk.ˏ(stringExtra);
        if (ˏ == null) {
            due.ॱ(ॱ, new d(this) {
                final /* synthetic */ UpdateAppAction ˊ;

                public void ॱ(SessionDownloadTask sessionDownloadTask) {
                    if (sessionDownloadTask != null) {
                        this.ˊ.downloadTask(o_dwk, sessionDownloadTask);
                    }
                }
            });
        } else {
            downloadTask(o_dwk, ˏ);
        }
    }

    private void downloadTask(dwk o_dwk, SessionDownloadTask sessionDownloadTask) {
        h hVar = new h();
        hVar.ˊ(this.callback.ˊ());
        hVar.ˏ(sessionDownloadTask);
        hVar.ˏ(new ewe(this) {
            final /* synthetic */ UpdateAppAction ˏ;

            {
                this.ˏ = r1;
            }

            public void ॱ() {
                this.ˏ.callback.finish();
            }
        });
        o_dwk.ˏ(false, hVar);
    }

    public boolean useCacheProtocol() {
        return true;
    }

    public void onDestroy() {
        super.onDestroy();
    }
}
